package com.lyf.core.rx;

import com.lyf.core.data.protocol.BaseDataBean;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.functions.Function;

public class BaseFunc<T extends BaseDataBean> implements Function<T, Observable<T>> {

    @Override
    public Observable<T> apply(T tBaseResp){
        //请求成功
        if (tBaseResp.getCode()==RespondCode.SERVICE_CODE_SUCCESS || tBaseResp.getCod()==RespondCode.SERVICE_CODE_SUCCESS){
            return Observable.just(tBaseResp);
        }
        return Observable.error(new BaseException(tBaseResp.code,tBaseResp.message));
    }
}
